home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue61 / misc / steffler / MakingSmalltalk-Article3.st < prev    next >
Encoding:
Text File  |  2002-08-14  |  5.3 KB  |  164 lines

  1. Browser subclass: #ScopedBrowser
  2.     instanceVariableNames: 'includedCategories excludedClasses '
  3.     classVariableNames: ''
  4.     poolDictionaries: ''
  5.     category: 'MakingSmalltalk-Article3'!
  6.  
  7. !ScopedBrowser methodsFor: 'class list' stamp: 'JRS 11/14/2000 09:49'!
  8. classList
  9.     "Override this method to:
  10.         * look up the category index from the system category list, as the browser category index is expected to be different than the system category lists index.
  11.         * reject any excluded classes
  12.     Answer an array of the class names of the selected category. Answer an empty array if no selection exists."
  13.  
  14.     systemCategoryListIndex = 0
  15.         ifTrue: [^Array new]
  16.         ifFalse: [^(systemOrganizer listAtCategoryNumber: (systemOrganizer categories 
  17.                     indexOf: self selectedSystemCategoryName asSymbol)) 
  18.                     reject: [:e | self excludedClasses includes: e name]].! !
  19.  
  20.  
  21. !ScopedBrowser methodsFor: 'system category list' stamp: 'JRS 11/19/2000 09:16'!
  22. systemCategoryList
  23.     "Override this method to answer the scoped class categories modeled by the receiver."
  24.  
  25.     ^self includedCategories select: [:e | systemOrganizer categories includes: e]! !
  26.  
  27.  
  28. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:05'!
  29. excludedClasses 
  30.  
  31.     ^excludedClasses ! !
  32.  
  33. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:06'!
  34. excludedClasses: aCollectionOfClasses 
  35.  
  36.     ^excludedClasses := aCollectionOfClasses.! !
  37.  
  38. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:05'!
  39. includedCategories
  40.  
  41.     ^includedCategories! !
  42.  
  43. !ScopedBrowser methodsFor: 'accessing' stamp: 'JRS 11/14/2000 09:06'!
  44. includedCategories: aCollectionOfCategories
  45.  
  46.     ^includedCategories := aCollectionOfCategories! !
  47.  
  48. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  49.  
  50. ScopedBrowser class
  51.     instanceVariableNames: ''!
  52.  
  53. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 11/19/2000 09:09'!
  54. openBrowserWithCategories: aCollectionOfCategorySymbols 
  55.  
  56.     self openBrowserWithCategories: aCollectionOfCategorySymbols 
  57.         withoutClasses: OrderedCollection new
  58.         withLabelSuffix: 'Unknown scope'! !
  59.  
  60. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 11/19/2000 09:10'!
  61. openBrowserWithCategories: aCollectionOfCategorySymbols withoutClasses: aCollectionOfClassSymbols
  62.  
  63.     self openBrowserWithCategories: aCollectionOfCategorySymbols 
  64.         withoutClasses: aCollectionOfClassSymbols
  65.         withLabelSuffix: 'Unknown scope'! !
  66.  
  67. !ScopedBrowser class methodsFor: 'instance creation' stamp: 'JRS 11/19/2000 09:10'!
  68. openBrowserWithCategories: aCollectionOfCategorySymbols withoutClasses: aCollectionOfClassSymbols withLabelSuffix: aLabelSuffix
  69.  
  70.     | aScopedBrowser |
  71.  
  72.     aScopedBrowser := self new.
  73.     aScopedBrowser includedCategories: aCollectionOfCategorySymbols.
  74.     aScopedBrowser excludedClasses: aCollectionOfClassSymbols.
  75.     self openBrowserView: (aScopedBrowser openEditString: nil)
  76.             label: 'Scoped Browser: ', aLabelSuffix        ! !
  77.  
  78.  
  79. !ScopedBrowser class methodsFor: 'instance creation - Making Smalltalk' stamp: 'JRS 11/19/2000 09:17'!
  80. openBrowserForArticle3
  81.  
  82.     self openBrowserWithCategories: (OrderedCollection new 
  83.             add: 'Collections-Abstract' asSymbol; 
  84.             add: 'Collections-Sequenceable' asSymbol;
  85.             add: 'Collections-Unordered' asSymbol;
  86.             yourself)
  87.         withoutClasses: (OrderedCollection new
  88.             add: #ArrayedCollection;
  89.             add: #SharedQueue;
  90.             add: #MappedCollection;
  91.             add: #Interval;
  92.             add: #IdentityDictionary;
  93.             add: #IdentitySet;
  94.             add: #PluggableDictionary;
  95.             add: #PluggableSet;
  96.             yourself)
  97.         withLabelSuffix: 'Making Smalltalk - Article 3 scope'! !
  98.  
  99.  
  100. !ScopedBrowser class methodsFor: 'qa testing' stamp: 'JRS 11/19/2000 09:19'!
  101. openBrowserTest
  102.     "Test creation method"
  103.  
  104.     self openBrowserWithCategories: (OrderedCollection new 
  105.             add: 'Jason-Testing' asSymbol; 
  106.             add: 'Collections-Abstract' asSymbol;
  107.             yourself)! !
  108.  
  109. !ScopedBrowser class methodsFor: 'qa testing' stamp: 'JRS 11/19/2000 09:19'!
  110. openBrowserTest2
  111.     "Test creation method"
  112.  
  113.     self openBrowserWithCategories: (OrderedCollection new 
  114.             add: 'Jason-Testing' asSymbol; 
  115.             add: 'Collections-Abstract' asSymbol;
  116.             yourself)
  117.         withoutClasses: (OrderedCollection new
  118.             add: #Collection;
  119.             yourself)! !
  120.  
  121. !ScopedBrowser class methodsFor: 'qa testing' stamp: 'JRS 11/19/2000 09:18'!
  122. openBrowserTest3
  123.     "Test creation method"
  124.  
  125.     self openBrowserWithCategories: (OrderedCollection new 
  126.             add: 'Collections-Abstract' asSymbol;
  127.             yourself)
  128.         withoutClasses: (OrderedCollection new
  129.             add: #Collection;
  130.             yourself)
  131.         withLabelSuffix: 'Testing Scope'! !
  132.  
  133. !ScopedBrowser class methodsFor: 'qa testing' stamp: 'JRS 11/19/2000 09:21'!
  134. openBrowserTest4
  135.     "Test instantiating with a non-existant category"
  136.  
  137.     self openBrowserWithCategories: (OrderedCollection new 
  138.             add: 'asdfasdfd-ereeff' asSymbol; 
  139.             add: 'Collections-Abstract' asSymbol;
  140.             yourself)
  141.         withoutClasses: (OrderedCollection new
  142.             add: #Collection;
  143.             yourself)
  144.         withLabelSuffix: 'Testing nonexistant category'! !
  145.  
  146. !ScopedBrowser class methodsFor: 'qa testing' stamp: 'JRS 11/19/2000 09:21'!
  147. openBrowserTest5
  148.     "Test instantiating with a non-existant class to exclude"
  149.  
  150.     self openBrowserWithCategories: (OrderedCollection new 
  151.             add: 'asdfasdfd-ereeff' asSymbol; 
  152.             add: 'Collections-Abstract' asSymbol;
  153.             yourself)
  154.         withoutClasses: (OrderedCollection new
  155.             add: #Aadfdfefff;
  156.             yourself)
  157.         withLabelSuffix: 'Testing nonexistant class'! !
  158.  
  159.  
  160. !ScopedBrowser class methodsFor: 'testing' stamp: 'JRS 11/19/2000 09:20'!
  161. version
  162.  
  163.     ^1.0! !
  164.